
using System;
using System.Data;
using System.IO;
using System.IO.Compression;
using System.Text;
using UnityEngine;

public static class IdHelper
{
    public static Guid GetGuid(string str)
    {
        string md5 = AssetHelper.GetStrMD5Hash(str, 32);
        string guid = GetFormartId(md5);
        return new Guid(guid);
    }
    public static string GetFormartId(string guid)
    {
        if (guid.Length < 32)
        {
            Debug.LogError($"{guid}字符串长度小于32");
            return "";
        }
        string guid1 = guid.Substring(0, 8);
        string guid2 = guid.Substring(8, 4);
        string guid3 = guid.Substring(12, 4);
        string guid4 = guid.Substring(16, 4);
        string guid5 = guid.Substring(20, 12);
        guid = $"{guid1}-{guid2}-{guid3}-{guid4}-{guid5}";
        return guid;
    }
    public static string GetCompressGuid()
    {
        return Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Replace("==", "");
    }
    public static string GetCompressGuid(Guid guid)
    {
        return Convert.ToBase64String(guid.ToByteArray()).Replace("==", "");
    }
}
